#define MAXSIZE 100 

typedef double QElemType;

typedef struct{
	QElemType *base;
	int front;
	int rear;
}Queue;

bool InitQueue(Queue& q){
	q.base=new QElemType[MAXSIZE];
	if(!q.base)
		exit(0);
	q.front=q.rear=0;
	return true;

}
void DestroyQueue(Queue& q){
	if(q.base != 0)
		delete q.base;
	q.rear = q.front =0;

}
void ClearQueue(Queue& q){
	q.rear = q.front =0;
}

bool QueueEmpty(Queue q){
	return q.front == q.rear? true : false;                           
 }

bool QueueFull(Queue q){
	return (q.rear -q.front +MAXSIZE)% MAXSIZE==1? true : false; 
}

bool GetHead(Queue q, QElemType& e){
	if(q.front!=q.rear)
		return false;
	e=q.base[q.front];
	return true;
}

bool EnQueue(Queue &q, QElemType e){
	if(QueueFull(q))
		return false;
   
	q.base[q.rear]=e;
	q.rear=(q.rear+1)%MAXSIZE;
	return true;
}

bool DeQueue(Queue &q, QElemType &e){
	if(QueueEmpty(q)) 
		return false;

	e=q.base[q.front];
	q.front=(q.front+1)%MAXSIZE;
	return true;
}